# Contributor: Keith Maxwell <keith.maxwell@gmail.com>
# Maintainer: Keith Maxwell <keith.maxwell@gmail.com>
pkgname=py3-grpcio
pkgver=1.41.0
pkgrel=1
pkgdesc="gRPC Python HTTP/2-based RPC framework"
url="https://grpc.io"
arch="all !ppc64le"  # no ppc64le -needs UnscaledCycleClock::Frequency()
license="Apache-2.0"
makedepends="
	c-ares-dev
	cython
	linux-headers
	openssl1.1-compat-dev
	python3-dev
	py3-setuptools
	py3-six
	re2-dev
	zlib-dev
	"
options="!check" # tests depend upon bazel
_abseil_cpp_rev=997aaf3a28308eba1b9156aa35ab7bca9688e9f6
source="grpc-$pkgver.tar.gz::https://github.com/grpc/grpc/archive/v$pkgver.tar.gz
	abseil-cpp-$_abseil_cpp_rev.tar.gz::https://github.com/abseil/abseil-cpp/archive/$_abseil_cpp_rev.tar.gz
	"

builddir="$srcdir/grpc-$pkgver"

unpack() {
	default_unpack

	# the archive is missing git submodules
	rmdir "$builddir/third_party/abseil-cpp"
	ln -sn "$srcdir/abseil-cpp-$_abseil_cpp_rev/" "$builddir/third_party/abseil-cpp"
}

export GRPC_PYTHON_DISABLE_LIBC_COMPATIBILITY=1
export GRPC_PYTHON_BUILD_SYSTEM_CARES=1
export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
export GRPC_PYTHON_BUILD_SYSTEM_RE2=1
export GRPC_PYTHON_BUILD_CYTHON=1

build() {
	python3 setup.py build
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"
}

sha512sums="
bc353bfd8cc10d8b992e4cf680c656ef6ddbcecbaa640c94e9255664d532926e48f3839afc98ef6278ae4e2eb54d166ac67fec7315dc1d08640845ed8120d902  grpc-1.41.0.tar.gz
bdd80a2278eef121e8837791fdebca06e87bfff4adc438c123e0ce11efc42a8bd461edcbbe18c0eee05be2cd6100f9acf8eab3db58ac73322b5852e6ffe7c85b  abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz
"
